import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace ActivityInfoApi {
  /** 活动信息 */
  export interface ActivityInfo {
    id?: number;
    communityId?: number;
    merchantId?: number;
    categoryId?: number;
    title?: string;
    coverImage?: string;
    bannerImage?: string;
    images?: string;
    description?: string;
    content?: string;
    venueId?: number;
    address?: string;
    longitude?: number;
    latitude?: number;
    startTime?: Date;
    endTime?: Date;
    signupStartTime?: Date;
    signupEndTime?: Date;
    maxParticipants?: number;
    currentParticipants?: number;
    pointReward?: number;
    experienceReward?: number;
    serviceHours?: number;
    activityStatus?: number;
    isRecommend?: number;
    isHot?: number;
    organizer?: string;
    contactPerson?: string;
    contactPhone?: string;
    attachments?: string;
    viewCount?: number;
    likeCount?: number;
    shareCount?: number;
    commentCount?: number;
    rating?: number;
    sort?: number;
    createTime?: Date;
    updateTime?: Date;
  }
}

/** 查询活动信息分页 */
export function getActivityInfoPage(params: PageParam) {
  return requestClient.get<PageResult<ActivityInfoApi.ActivityInfo>>(
    '/cmt/activity-info/page',
    { params },
  );
}

/** 查询活动信息详情 */
export function getActivityInfo(id: number) {
  return requestClient.get<ActivityInfoApi.ActivityInfo>(
    `/cmt/activity-info/get?id=${id}`,
  );
}

/** 新增活动信息 */
export function createActivityInfo(data: ActivityInfoApi.ActivityInfo) {
  return requestClient.post('/cmt/activity-info/create', data);
}

/** 修改活动信息 */
export function updateActivityInfo(data: ActivityInfoApi.ActivityInfo) {
  return requestClient.put('/cmt/activity-info/update', data);
}

/** 删除活动信息 */
export function deleteActivityInfo(id: number) {
  return requestClient.delete(`/cmt/activity-info/delete?id=${id}`);
}

/** 批量删除活动信息 */
export function deleteActivityInfoList(ids: number[]) {
  return requestClient.delete(
    `/cmt/activity-info/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出活动信息 */
export function exportActivityInfo(params: any) {
  return requestClient.download('/cmt/activity-info/export-excel', { params });
}

/** 获取活动选项列表(用于下拉选择) */
export function getActivityInfoOptions() {
  return requestClient.get<PageResult<ActivityInfoApi.ActivityInfo>>(
    '/cmt/activity-info/page',
    { params: { pageNo: -1, pageSize: 10 } },
  );
}
